﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.Unity;
using System.ServiceModel.Activation;
using Skynet.BusinessEntities;

namespace Skynet.ServiceImplementation
{
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class SkynetLibraryJson : ServiceContracts.ISkynetLibraryJson
    {
        [Dependency]
        public BusinessLogic.BusinessComponents.IBCExams BCExams { get; set; }
        [Dependency]
        public Infrastructure.Aspect.Services.Traslator.IEntityTranslatorService EntityTranslatorService { get; set; }

        [Dependency]
        public Infrastructure.Aspect.Inspectors.IMethodAuditService MethodAuditService { get; set; }

        [Dependency]
        public BusinessLogic.BusinessComponents.IBCExamQueries BCExamQueries { get; set; }

        public string GetSystemDate()
        {
            return new DateTime().ToString("dddd, MMMM dd, yyyy");                         
        }
        public List<ExamCategory> ExamCategories()
        {
            var categories = this.BCExamQueries.SearchExamCategories();
            var query = from c in categories select c;
            var result = this.EntityTranslatorService.Translate<IEnumerable<ExamCategory>>(query);            

            return result.ToList();
        }

        


        public void RegisterMethodInterceptor(Guid Id, string Solution, Guid Application, Guid Operation, string Module, string ClassName, string MethodName)
        {
            var method = new Infrastructure.Aspect.Inspectors.MethodAudit();
            method.Id = Id;
            method.Solution = Solution;
            method.Application = Application; 
            method.Module = Module; 
            method.ClassName = ClassName;
            method.Method = MethodName;
            method.Operation = Operation;
            this.MethodAuditService.AddMethodAudit(method);
        }

        

        #region ISkynetLibraryJson Members


        public List<Infrastructure.Aspect.Inspectors.MethodAudit> GetMethodAuditInfo()
        {
            return this.MethodAuditService.GetAll();
        }

        #endregion
    }
}
